﻿using System.Windows.Forms;
using System;

namespace orb
{
    public class GuiRunner: Form
    {
        public GuiRunner()
        {
            WindowState = FormWindowState.Minimized;
            ShowInTaskbar = false;
            VisibleChanged += new EventHandler(GuiRunner_VisibleChanged);
        }

        void GuiRunner_VisibleChanged(object sender, EventArgs e)
        {
            Hide();
        }

        public void RunOnGuiThread(Action a)
        {
            if (InvokeRequired)
                Invoke( new MethodInvoker(a) );

            else
                a();
        }
    }
}
